/**
 *  右侧城市柱状图检验
 *  Created by lins on 2018/7/16.
 */
'use strict';
angular.module("MetronicApp").directive('transverseBar', function () {
    return {
        scope: {
            id: "@",
            data: "="
        },
        restrict: 'EA',
        template: '',
        replace: true,
        link: function ($scope, element, attrs, controller) {
            function getOption(data) {
                var option3 = {
                    color: ['#2EC7C9'],
                    grid: {
                        left: '3%',
                        right: '0%',
                        bottom: '3%',
                        containLabel: true
                    },
                    xAxis : [
                        {
                            type : 'category',
                            data : ['石家庄市', '秦皇岛市', '邢台市', '张家口市', '沧州市', '衡水市'],

                        }
                    ],
                    yAxis : [
                        {
                            type : 'value'
                        }
                    ],
                    series : [
                        {
                            type:'bar',
                            barWidth: '30%',
                            data:[410, 52, 200, 234, 390, 130, 400],
                            itemStyle: {
                                normal: {
                                    //柱形图圆角，初始化效果
                                    barBorderRadius:[5, 5, 5, 5]
                                }
                            }
                        },
                        {
                            type:'bar',
                            barWidth: '30%',
                            data:[50, 352, 110, 334, 90, 330, 20],
                            itemStyle: {
                                normal: {
                                    //柱形图圆角，初始化效果
                                    barBorderRadius:[5, 5, 5, 5]
                                }
                            }
                        }


                    ]

                };
                return option3;
            }

            var myChart = echarts.init(document.getElementById('second'), 'macarons');
            myChart.setOption(getOption($scope.data));

            $scope.$watch('data', function (newVal, oldVal) {
                myChart.setOption(getOption(newVal));
            });
        }
    };
});
